import math

def factchain(n):
	return sum(map(math.factorial, map(int, str(n))))

chainsize = {145:1, 169:3, 871:2, 872:2, 363601:3, 1454:3, 45361:2, 45362:2, 2:1, 1:1, 40585:1}

def chain(n) :
	try :
		return chainsize[n]
	except KeyError :
		chainsize[n] = 1+chain(factchain(n))
		return chainsize[n]

sixties = []
for i in range(1000000) :
	if chain(i) == 60 :
		print i
		sixties.append(i)
print "== :", len(sixties)
sixties = []
for i in range(1000000) :
	if chain(i) >= 60 : sixties.append(i)
print ">= :", len(sixties)